package com.zz.node;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 张哲
 * @email a252013135@163.com
 * @date 2024/9/12 15:06
 * <p>
 * 倒序打印链表
 */
public class Offer6 {
    public void reverNode(ListNode listNode) {
        ListNode node = listNode;
        List<ListNode> arr = new ArrayList<ListNode>();
        while (node != null) {
            arr.add(node);
            node = node.next;
        }
        for (int i = arr.size() - 1; i >= 0; i--) {
            System.out.print(arr.get(i).val + "\t");
        }
    }
}
